package com.qqpz.sign_project.service.impl;

import com.qqpz.sign_project.entity.Courses;
import com.qqpz.sign_project.mappers.AdminMapper;
import com.qqpz.sign_project.mappers.CoursesMapper;
import com.qqpz.sign_project.service.CoursesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 吴刚
 * @project sign_project/com.qqpz.sign_project.service.impl
 * @time 2021/6/28 15:27
 */
@Service
public class CoursesServiceImpl implements CoursesService {
    @Autowired
    private CoursesMapper coursesMapper;

    @Override
    public List<Courses> queryCoursesInfo() {
        return coursesMapper.queryCoursesInfo();
    }

    @Override
    public List<Courses> queryByUserName(String username) {
        return coursesMapper.queryByUserName(username);
    }

    @Override
    public List<Courses> queryByNameAccurate(String name) {
        return coursesMapper.queryByNameAccurate(name);
    }

    @Override
    public List<Courses> queryByName(String name) {
        return coursesMapper.queryByName(name);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertCourses(Courses courses) {
        int i;
        try{
            coursesMapper.insertCourses(courses);
            i=1;
        }catch (Exception e){
            i=0;
        }
        return i;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateCourses(Courses courses) {

        return coursesMapper.updateCourses(courses);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteCoursesById(String id) {
        return coursesMapper.deleteCoursesById(id);
    }

    @Override
    public Courses queryById(String id) {
        return coursesMapper.queryById(id);
    }

    @Override
    public String queryAddress(String id) {
        return coursesMapper.queryAddress(id);
    }
}
